var balance;
findDetails()
function findDetails(){
	$.ajax({
        url:  urlcore +"/api/channel/getThisLogin",
        type: "get",
        contentType: "application/json;charset=utf-8",
        dataType: "json",
        success:function(data){
            if (data.success == true) {
            	var n = data.data;
            	balance = n.balance;
            	$('#balance').val(n.balance);
            } else {
                alert(data.msg);
            }
        },
        error: function() {
            alert("error");
        }

    });
}


function subMsg(){
	var money = $('#money').val();
	var bankNumber = $('#bankNumber').val();
	var userName = $('#userName').val();
   	if(money==''){
     	alert("不完整信息！");
     	return false;
     }
   	if(bankNumber==''){
     	alert("不完整信息！");
     	return false;
     }
   	if(userName==''){
     	alert("不完整信息！");
     	return false;
     }
   	if (Number(balance)<Number(money)) {
   		alert("余额不足！");
     	return false;
   	}
     $.ajax({
        url:  urlcore +"/api/withdrawChannel/add",
        type: "post",
        contentType: "application/json;charset=utf-8",
        data: JSON.stringify({
        	"money":money,
        	"bankNumber":bankNumber,
        	"userName":userName
        }),
        dataType: "json",
        success:function(data){
            if (data.success == true) {
                    location.reload()
                  } else if (data.code == 'OVERTIME') {
                var thisUrl = window.location.href;
                if (thisUrl.indexOf('login.html') <= -1) {
                    top.window.location.href = "login.html";
                }
            } else {
                alert(data.msg);
            }

        },
        error: function() {
            alert("error");
        }

    });
	
	
}
